package com.java.core.enumpackage;

import com.alibaba.fastjson.JSONObject;

/**
 * @Author YongQiang
 * @Date 2021/9/26 14:07
 * @Version 1.0
 */
public class EnumTest {
    public static void main(String[] args) {
        // values返回包含全部枚举值的数组
        WeekEnum[] values = WeekEnum.values();
        String json = JSONObject.toJSONString(values);
        System.out.println(json);

        WeekEnum sunday = WeekEnum.valueOf("Sunday");
        json = JSONObject.toJSONString(sunday);
        System.out.println(json);

        // ordinal返回枚举声明中枚举常量的位置
        System.out.println(WeekEnum.Monday.ordinal());

    }
}
